//
function exportFinishReport(){
	//params
	var exhName=getValueById("exhName");
	var backupCode= getValueById("backupCode");
	var preEntName= getValueById("preEntName");
	var undEntName= getValueById("undEntName");
	var agentEntName= getValueById("agentEntName");
	var beginDate= getValueById("beginDate");
	var endDate= getValueById("endDate");
	var exhAddress= getValueById("exhAddress");
	var exhArea= getValueById("exhArea");
	var exhHall= getValueById("exhHall");
	
	var nowDate= getValueById("nowDate");
	var declCount= getValueById("declCount");
	var pCount= getValueById("pCount");
	var qCount= getValueById("qCount");
	var rCount= getValueById("rCount");
	var sCount= getValueById("sCount");
	var mCount= getValueById("mCount");
	var nCount= getValueById("nCount");
	var lCount= getValueById("lCount");
	var nonCount= getValueById("nonCount");
	
	var declNoAAAs=getValueById("declNoAAA");
	var declNoBBBs=getValueById("declNoBBB");
	var declNoCCCs=getValueById("declNoCCC");
	var declNoDDDs=getValueById("declNoDDD");
	var declNoEEEs=getValueById("declNoEEE");
	var declNoFFFs=getValueById("declNoFFF");
	var declNoGGGs=getValueById("declNoGGG");
	var declNoHHHs=getValueById("declNoHHH");
	
	var checkCount1= getValueById("checkCount1");
	var checkCount2= getValueById("checkCount2");
	var custodyCount1= getValueById("custodyCount1");
	var custodyCount2= getValueById("custodyCount2");
	var declNoIIIs=getValueById("declNoIII");
	var declNoJJJs=getValueById("declNoJJJ");
	var declNoKKKs=getValueById("declNoKKK");
	var declNoLLLs=getValueById("declNoLLL");
	
	//create doc
	var ref=document.location.href.substr(0,document.location.href.indexOf("/app"));
	word.Documents.Open(ref+"/doc/FinishReport.doc");
	
//string
	insertWordByBookmark("exhName",exhName);
	insertWordByBookmark("exhName1",exhName);
	insertWordByBookmark("backupCode",backupCode);
	insertWordByBookmark("preEntName",preEntName);
	insertWordByBookmark("undEntName",undEntName);
	insertWordByBookmark("beginDate",beginDate);
	insertWordByBookmark("endDate",endDate);
	insertWordByBookmark("exhAddress",exhAddress);
	insertWordByBookmark("exhArea",exhArea);
	insertWordByBookmark("exhHall",exhHall);
	insertWordByBookmark("nowDate",nowDate); 
	insertWordByBookmark("agentEntName",agentEntName); 
	insertWordByBookmark("declCount",declCount);
	insertWordByBookmark("pCount",pCount);
	insertWordByBookmark("qCount",qCount);
	insertWordByBookmark("rCount",rCount);
	insertWordByBookmark("sCount",sCount);
	insertWordByBookmark("mCount",mCount);
	insertWordByBookmark("nCount",nCount);
	insertWordByBookmark("lCount",lCount);
	insertWordByBookmark("nonCount",nonCount);
	
	insertWordByBookmark("declNoAAAs",(declNoAAAs));
	insertWordByBookmark("declNoBBBs",(declNoBBBs));
	insertWordByBookmark("declNoCCCs",(declNoCCCs));
	insertWordByBookmark("declNoDDDs",(declNoDDDs));
	insertWordByBookmark("declNoEEEs",(declNoEEEs));
	insertWordByBookmark("declNoFFFs",(declNoFFFs));
	insertWordByBookmark("declNoGGGs",(declNoGGGs));
	insertWordByBookmark("declNoHHHs",(declNoHHHs));
	
	insertWordByBookmark("checkCount1",checkCount1);
	insertWordByBookmark("checkCount2",checkCount2);
	insertWordByBookmark("custodyCount1",custodyCount1);
	insertWordByBookmark("custodyCount2",custodyCount2);
	insertWordByBookmark("declNoIIIs",(declNoIIIs));
	insertWordByBookmark("declNoJJJs",(declNoJJJs));
	insertWordByBookmark("declNoKKKs",(declNoKKKs));
	insertWordByBookmark("declNoLLLs",(declNoLLLs));

//table
	var tbody_1=getInnerTextByIdFromTBody("tbody1",3);
    var tbody_2=getInnerTextByIdFromTBody("tbody2",12);
	insertWordByTable(tbody_1,1,3);
	insertWordByTable(tbody_2,2,12);

	word.Visible=true;
	delete word;
	return ;
}

/////////////////////////////////////
function insertWordByTable(arr,ord,colNum){
	var table=word.ActiveDocument.Tables(ord);
	var rowNum=arr.length/colNum;
	var row=table.Rows(1);//
	for(var i=0;i<rowNum-1;i++){
		table.Rows.Add();
	}
	var k=0;
	for(var i=2;i<=(rowNum+1);i++){
		for(var j=1;j<=colNum;j++){
			table.Cell(i,j).Range.Text=arr[k];
			k++;
		}
	}
}

function getInnerTextByIdFromTBody(tbodyStr,col){
	if(tbodyStr==null||$(tbodyStr)==null){
		return new Array(0);
	}
	var tbody=$(tbodyStr);
	if(tbody.rows==null||tbody.rows.length==0){
		return new Array(0);
	}
	var arr=new Array(tbody.rows.length*col);
	var tr;
	var td;
	var e;
	var k=0;
	var s="";
	for(var i=0;i<tbody.rows.length;i++){
		tr=tbody.rows(i);
		for(var j=0;j<tr.cells.length;j++){
			td=tr.cells(j);
			for(var t=0;t<td.children.length;t++){
				e=td.children(t);
				if(e!=null&&e.innerText!=null){
					s+=e.innerText;
				}else{
					s+="";
				}
			}
			arr[k]=s;
			s="";
			k++;
		}
	}
	return arr;
}


/////////
function getInnerTextById1(id,zone,tag){
	if(tag==null) tag="span";
	var arr=new Array();
	if(zone==null||$(zone)==null){
   	return arr;
   }
	var allEle=$(zone).children;
	var e;
	var s;
	for(var i=0 ,j=0;i<allEle.length;i++){
		e=allEle(i);
		if(e!=null && typeof e=="object" && e.id!=null){
			if(e.id==id){
				s=e.innerText;
				if(s!=null){
					arr[j]=s;
					j++;
				}
			}
		}
	}
	return arr;
}

function getInnerTextById2(id,zone,tag){
	if(tag==null) tag="span";
	var arr=new Array();
	if(id!=null){
		var ids=$(id);
		alert("ids.tagName="+ids.tagName+"   ids.innerText="+ids.innerText);

		if(ids!=null&&ids.length!=0){
			for(var i=0,j=0;i<ids.length;i++){
				if(ids(i).tagName!=null&&ids(i).tagName.toLowerCase()==tag&&ids(i).innerText!=null){
					arr[j]=ids(i).innerText;
					j++;
				}
			}
		}
	}
	return new Array(0);
}



function tranArrayToString(arrayObj,sep){
	if(sep==null) sep="、";
	var s=arrayObj.join(sep);
	return s;
}

function CensorFinish_OnSubmit(){
	
	if(DWRUtil.getValue("statusStr").substr(1)=="audit"&&DWRUtil.getValue("spCensorResult1")=="0"){
		alert("请选择审核结果");
		return false;
	}
	return window.confirm("审核的结果提交后不可更改，您确定吗？");
}

function insertWordByBookmark(name,value,replace){
	range=word.ActiveDocument.Bookmarks(name).Range;
	if(replace==null||replace==true){
		range.Text=value;
	}else if(replace==false){
		range.InsertAfter(value); 
	}
}

function getValueById(id){
	if(id==null||$(id)==null)
		return "";
	var s=DWRUtil.getValue(id);
	if(s==null){
		s="";
	}
	return s;
}
